//package com.yunhe.device.controller.base;
//
//import com.yunhe.common.model.PageParam;
//import com.yunhe.device.domain.base.BaseVoltage;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.base.BaseVoltageService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 基础电压Controller
// * @author liuronglei
// */
//@Api(value = "baseVoltage",description = "基础电压维护", tags = {"Base_BaseVoltage"})
//@RestController
//@RequestMapping("/baseVoltages")
//public class BaseVoltageController {
//    @Autowired
//    private BaseVoltageService baseVoltageService;
//
//    /**
//     * 新增基础电压
//     * @param systemId 系统ID
//     * @param baseVoltage 基础电压对象
//     */
//    @ApiOperation("新增基础电压")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path")
//    })
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@PathVariable("systemId") String systemId,
//                                             @RequestBody BaseVoltage baseVoltage)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        BaseVoltage newBaseVoltage = baseVoltageService.createBaseVoltage(baseVoltage);
//        return new ResponseEntity<>(new ResultObject<>(newBaseVoltage), HttpStatus.OK);
//    }
//
//    /**
//     * 批量新增基础电压
//     * @param systemId 系统ID
//     * @param domainList 基础电压对象列表
//     */
//    @ApiOperation("批量新增基础电压")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path")
//    })
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@PathVariable("systemId") String systemId,
//                                             @RequestBody DomainList<BaseVoltage> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        Iterable<BaseVoltage> newBaseVoltages = baseVoltageService.createBaseVoltage(domainList.getList());
//        return new ResponseEntity<>(new ResultObject<>(newBaseVoltages), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除基础电压
//     * @param systemId 系统ID
//     * @param id id
//     */
//    @ApiOperation("根据ID删除基础电压")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "基础电压ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("systemId") String systemId,
//                                               @PathVariable("id") Long id) {
//        baseVoltageService.deleteBaseVoltage(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码删除基础电压
//     * @param systemId 系统ID
//     * @param code 代码
//     */
//    @ApiOperation("根据代码删除基础电压")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> deleteByCode(@PathVariable("systemId") String systemId,
//                                                     @PathVariable("code") Long code) {
//        Long result = baseVoltageService.deleteBaseVoltageByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    /**
//     * 更新基础电压（更新全部字段）
//     * @param systemId 系统ID
//     * @param id ID
//     * @param baseVoltage 基础电压对象
//     */
//    @ApiOperation("更新基础电压（更新全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method =  RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(@PathVariable("systemId") String systemId,
//                                            @PathVariable("id") Long id,
//                                            @RequestBody BaseVoltage baseVoltage)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        baseVoltage.setId(id);
//        BaseVoltage newBaseVoltage = baseVoltageService.updateBaseVoltage(baseVoltage);
//        return new ResponseEntity<>(new ResultObject<>(newBaseVoltage), HttpStatus.OK);
//    }
//
//    /**
//     * 更新基础电压（更新指定字段）
//     * @param systemId 系统ID
//     * @param id ID
//     * @param code 代码
//     */
//    @ApiOperation("更新基础电压（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType="Long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "代码", dataType = "Long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "nomKV", value = "电压值", dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(@PathVariable("systemId") String systemId,
//                                              @PathVariable("id") Long id,
//                                              @RequestParam("code") Optional<Long> code,
//                                              @RequestParam("name") Optional<String> name,
//                                              @RequestParam("nomKV") Optional<Double> nomKV)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        BaseVoltage newBaseVoltage = baseVoltageService.updateBaseVoltage(id, code.orElse(null), name.orElse(null), nomKV.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newBaseVoltage), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID获得基础电压对象
//     * @param systemId 系统ID
//     * @param id ID
//     */
//    @ApiOperation("根据ID获得基础电压对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "对象ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(@PathVariable("systemId") String systemId,
//                                            @PathVariable("id") Long id) {
//        BaseVoltage baseVoltage = baseVoltageService.findByBaseVoltageId(id);
//        return new ResponseEntity<>(new ResultObject<>(baseVoltage), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码获得基础电压对象
//     * @param systemId 系统ID
//     * @param code 代码
//     */
//    @ApiOperation("根据代码获得基础电压对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByCode(@PathVariable("systemId") String systemId,
//                                                  @PathVariable("code") Long code) {
//        BaseVoltage baseVoltage = baseVoltageService.findByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(baseVoltage), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得基础电压列表
//     * @param systemId 系统ID
//     */
//    @ApiOperation("根据条件获得基础电压列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "String", paramType = "path")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(@PathVariable("systemId") String systemId,
//                                               @ModelAttribute PageParam pageParam) {
//        Iterable<BaseVoltage> results = baseVoltageService.findBaseVoltages(pageParam);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}